var myTimeInterval = window.setInterval(myTime, 1000);

function myTime(){
    var date = new Date();
    var time = date.toLocaleTimeString();
    document.getElementById("time").innerHTML = time;
}

function stopMyTime(){
    window.clearInterval(myTimeInterval);
    console.log("Hava stopped myTime")
}


window.setTimeout(function(){
    alert("This is setTimeout");
}, 3000);